<?php
    $user_id    = $this->element->getValue(false);
?>
<dt>
    <?= $this->formLabel($this->element->getName(), $this->element->getLabel()); ?>
</dt>
<dd>
    <?php
        $printselect = true;
        $UserMapper  = new Application_Model_UserMapper();
        
        if(strlen($user_id))
        {
            $User   = $UserMapper->fetchById($user_id);
            if($User)
            {
                $printselect = false;
                echo '<input type="hidden" name="'.$this->element->getName().'" value="'.$user_id.'" />';
                echo '<span class="hiddeninputfield">'.$User->Givenname . ' ' . $User->Familyname.'</span>';
            }
        }
        
        if($printselect)
        {
            $AllUsers   = $UserMapper->fetchAll();

            echo '<select name="'.$this->element->getName().'">';
                echo '<option></option>';

                foreach($AllUsers as $User)
                {
                    echo '<option value="'.$User->Id.'"'.($user_id == $User->Id ? ' selected="selected"' : '').'>'
                            .$User->Givenname . ' ' . $User->Familyname
                        .'</option>';
                }

            echo '</select>';
        }
    ?>
 
    <?php if(count($this->element->getMessages()) > 0): ?>
        <?= $this->formErrors($this->element->getMessages()); ?>
    <?php endif; ?>
</dd>